package datasource

import (
	"context"
	"iris-starter/config"
	"log"

	"github.com/go-redis/redis/v8"
)

var RdsClient *redis.Client

func InitRedis(cfg *config.Config) {
	rds := cfg.Redis
	RdsClient = redis.NewClient(&redis.Options{
		Addr:     rds.Addr,
		Password: rds.Password,
		DB:       rds.Db,
	})
	err := RdsClient.Ping(context.Background()).Err()
	if err != nil {
		log.Fatalf("redis connect error:%v", err)
	}
}
